package com.pet.mapper;

import com.github.pagehelper.Page;
import com.pet.entity.PetAdoptApplication;
import com.pet.entity.PetAdoptInfo;
import com.pet.pageDto.PetAdoptApplicationPageDTO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PetAdoptApplicationMapper {

    /**
     * 添加
     * @param petAdoptApplication
     */
    @Insert("insert into pet_manage_system.pet_adopt_application" +
            "(gender, experience, marriage, home, job, " +
            "age, area, phone, detail_information, application_user, " +
            "application_time,pet_id, wechat,pet_adopt_info_id) " +
            "VALUES " +
            "(#{gender}, #{experience}, #{marriage}, #{home}, #{job}," +
            "#{age}, #{area}, #{phone}, #{detailInformation}, #{applicationUser}," +
            "#{applicationTime},#{petId},#{wechat},#{petAdoptInfoId})")
    void insertPetAdoptApplication(PetAdoptApplication petAdoptApplication);

    /**
     * 根据用户id查询
     * @param currentId
     * @return
     */
    @Select("select * from pet_manage_system.pet_adopt_application where application_user = #{currentId}")
    List<PetAdoptApplication> selectPetAdoptApplication(Long currentId);

    /**
     * 根据id删除
     * @param id
     */
    @Delete("DELETE from pet_manage_system.pet_adopt_application where id =#{id}")
    void deletePetAdoptApplication(Long id);

    /**
     * 更新
     * @param dto
     */
    void updatePetAdoptApplication(PetAdoptApplication dto);

    /**
     * 根据petId删除
     * @param id
     */
    @Delete("delete from pet_manage_system.pet_adopt_application where pet_id =#{id}")
    void deletePetAdoptApplicationByPetId(Integer id);

    /**
     * 根据petId和状态查询信息
     * @param i
     * @return
     */
    @Select("select * from pet_manage_system.pet_adopt_application " +
            "where pet_id = #{i} and application_status =#{checkStatus}")
    PetAdoptApplication selectPetAdoptApplicationByPetIdAndStatus(Integer i, Integer checkStatus);

    /**
     * 根据petId查询Application
     * @param petId
     * @return
     */
    @Select("select * from pet_manage_system.pet_adopt_application where pet_id = #{petId}")
    List<PetAdoptApplication> selectPetAdoptApplicationByPetId(Long petId);

    @Delete("delete from pet_manage_system.pet_adopt_application where application_user = #{userId}")
    void deletePetAdoptApplicationByUserId(Integer userId);

    Page<PetAdoptApplication> pageQuery(PetAdoptApplicationPageDTO page);
}
